home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1988 / 05 / spmtplnt.c < prev    next >
Text File  |  1988-08-18  |  2KB  |  73 lines

  1. Written by Bill Hall, Olivetti ATC.
  2.  
  3. #define INCL_PM
  4. #include <os2.h>
  5. #include <stddef.h>
  6. #include "spmtpl.h"
  7.  
  8. BOOL FAR InitProgram(int argc, char *argv[])
  9. {
  10.  
  11.     char szTitle[50];
  12.  
  13.   /* get anchor block handle and message queue handles */
  14.     if ((hAB = WinInitialize(NULL)) == NULL)
  15.     return FALSE;
  16.  
  17.     if ((hmqMsgQ = WinCreateMsgQueue(hAB,0)) == NULL)
  18.         return FALSE;
  19.  
  20.   /* This string is needed to register the Window */
  21.     WinLoadString(hAB,NULL, IDS_APPNAME, sizeof(szAppName), (PSZ)szAppName);
  22.  
  23.     if (!WinRegisterClass(hAB,             /* anchor block handle */
  24.               (PCH)szAppName,     /* class name */
  25.               (PFNWP)MainWndProc,    /* window procedure for class */
  26.               CS_SIZEREDRAW,       /* class styles */
  27.               0))            /* no extra data needed */
  28.     return FALSE;
  29.  
  30.   /* This string is needed to create the frame window */
  31.     WinLoadString(hAB, NULL, IDS_TITLE, sizeof(szTitle), (PSZ)szTitle);
  32.  
  33.     hwndFrame = WinCreateStdWindow(HWND_DESKTOP,    /* parent */
  34.                                    WS_VISIBLE | FS_TITLEBAR   | /*frame style*/
  35.                                    FS_SYSMENU | FS_SIZEBORDER |
  36.                                    FS_MINMAX,
  37.                                    (PCH)szAppName,    /* class */
  38.                                    (PCH)szTitle,    /* window title */
  39.                                    0L,            /*default client style*/
  40.                                    (HMODULE)NULL,    /* resources in .EXE */
  41.                                    NULL,        /* frame id */
  42.                                    (HWND FAR *)&hwndMain);
  43.                             /* handle to client */
  44.  
  45.     if (hwndFrame) {
  46.         WinShowWindow(hwndFrame, TRUE);
  47.     return TRUE;
  48.     }
  49.     return FALSE;
  50. }
  51.  
  52. /* called when client is created */
  53. void FAR WndCreate(HWND hWnd)
  54. {
  55.  
  56.     FONTMETRICS FM;
  57.     HPS hPS;
  58.  
  59.   /* get the size of an icon */
  60.     xIconsize = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
  61.     yIconsize = WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
  62.  
  63.   /* load the icon string */
  64.     WinLoadString(hAB, NULL, IDS_ICON, (USHORT)sizeof(szIcon), (PSZ)szIcon);
  65.  
  66.   /* get the system font character metrics */
  67.     hPS = WinGetPS(hWnd);
  68.     GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &FM);
  69.     CharHeight = FM.lMaxBaselineExt + FM.lExternalLeading;
  70.     CharWidth = FM.lAveCharWidth;
  71.     WinReleasePS (hPS);
  72. }
  73.